package peer.rdp.command;

import peer.tools.Mdb;

public class TransCOM1 extends Command{
	Mdb mdb;
	int pieceNum=0;
	public TransCOM1(Mdb mdb,int pieceNum){
		this.mdb=mdb;
		this.pieceNum=pieceNum;
		data=new byte[22];
		commandType=peer.tools.CommandType.command_TransCom1;
		this.mdb=mdb;
		peer.tools.ByteShortSwitch.toByteArray(commandType, data, 0);
		System.arraycopy(mdb.md, 0, data, 2, 16);
		peer.tools.ByteIntSwitch.toByteArray(pieceNum, data, 18);
	}
	
	public TransCOM1(byte[] data){
		this.data=data;
		commandType=peer.tools.ByteShortSwitch.toShort(data, 0);
		byte[] md=new byte[16];
		System.arraycopy(data, 2, md, 0, 16);
		mdb=new Mdb(md);
		pieceNum=peer.tools.ByteIntSwitch.toInt(data, 18);
	}
	
	public Mdb getMdb(){
		return mdb;
	}
	
	public int getPieceNum(){
		return pieceNum;
	}
	
}
